<?php

// This file is part of the Carrington Mobile Theme for WordPress
// http://carringtontheme.com
//
// Copyright (c) 2008-2009 Crowd Favorite, Ltd. All rights reserved.
// http://crowdfavorite.com
//
// Released under the GPL license
// http://www.opensource.org/licenses/gpl-license.php
//
// **********************************************************************
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
// **********************************************************************

if (__FILE__ == $_SERVER['SCRIPT_FILENAME']) { die(); }
if (CFCT_DEBUG) { cfct_banner(__FILE__); }

cfct_form('search');

if (is_page()) {
	global $post;
	$parent = $post->ID;
	ob_start();
	wp_list_pages('title_li=&depth=1&child_of='.$parent);
	$sub_pages = ob_get_contents();
	ob_end_clean();
} else {
	$sub_pages = '';
}

if (!empty($sub_pages)) {
	$sub_pages = '<li><strong class="title">'.__('Sub Pages', 'carrington-mobile').'</strong></li>'.$sub_pages.'<li><strong class="title">'.__('Top Level Pages', 'carrington-mobile').'</strong></li>';
}

?>
<hr />

<div class="tabbed">
	<div id="hots_tab">
		<hr />
		<h2 class="table-title" id="hots"><?php _e('Tin hot'); ?></h2>
		<ul class="disclosure table group">
			<?php   
  				$args = array( 'meta_key' => 'Level','meta_value' =>'Hot','orderby'=> 'post_date','order'=> 'DESC');
				$myposts = get_posts( $args );
				foreach($myposts as $p) {
					echo '<li><a href="'.$p->guid.'">';
					if ( has_post_thumbnail($p->ID)) {
	   					echo get_the_post_thumbnail($p->ID, array(30,30), array('class' => 'alignleft'));
 					}else{
 						echo '<img width="30" height="30" src="'.get_bloginfo('siteurl').'/wp-content/uploads/2011/07/moba.jpg" class="alignleft wp-post-image" alt="moba" title="moba" />';
 					}  
					echo $p->post_title.' (<span class="date">'.date_format(date_create($p->post_date), 'd-m-Y').')</span><img class="thumb" src="'.get_bloginfo('siteurl').'/wp-content/uploads/2011/07/hot.gif" alt="" /></a>';
					echo '<span style="font-size:x-small;">';
					echo get_post_meta($p->ID,'Introduction',true);
					echo '</span><div style="clear:both"></div></li>';
				}
			?>
		</ul>
	</div>
	<div id="recent_tab">
		<hr />
		<h2 class="table-title" id="recent"><?php _e('Tin mới'); ?></h2>
		<ul class="disclosure table group">
			<!--<?php wp_get_archives('type=postbypost&limit=5'); ?>-->
			<?php   
  				$args = array( 'meta_key' => 'Level','meta_value' =>'New','orderby'=> 'post_date','order'=> 'DESC');
				$myposts = get_posts( $args );
				foreach($myposts as $p) {
					echo '<li><a href="'.$p->guid.'">';
					if ( has_post_thumbnail($p->ID)) {
	   					echo get_the_post_thumbnail($p->ID, array(30,30), array('class' => 'alignleft'));
 					}else{
 						echo '<img width="30" height="30" src="'. get_bloginfo('siteurl').'/wp-content/uploads/2011/07/moba.jpg" class="alignleft wp-post-image" alt="moba" title="moba" />';
 					}  
					echo $p->post_title.' (<span class="date">'.date_format(date_create($p->post_date), 'd-m-Y').')</span><img class="thumb" src="'.get_bloginfo('siteurl').'/wp-content/uploads/2011/07/new.gif" alt="" /></a>';
					echo '<span style="font-size:x-small;">';
					echo get_post_meta($p->ID,'Introduction',true);
					echo '</span><div style="clear:both"></div></li>';
				}
			?>
		</ul>
	</div>
	<div id="pages_tab">
		<hr />
		<h2 class="table-title" id="pages"><?php _e('Ứng dụng'); ?></h2>
		<ul class="disclosure table group">
			<?php echo $sub_pages; wp_list_pages('title_li=&depth=1'); ?>
		</ul>
	</div>
	
</div>

<hr />

<p id="navigation-bottom" class="navigation">
	<?php cfct_misc('main-nav'); ?>
</p>

<hr />

<?php

cfct_template_file('footer', 'bottom');

?>